﻿using System;

namespace NumbersToEnglish
{
    class Program
    {
        private static void Main(string[] args)
        {
            if (args == null) throw new ArgumentNullException("args");

            try
            {
                Int64 number;

                if (Int64.TryParse(args[0], out number))
                {
                    Console.WriteLine(Convert(number));
                    Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("Please enter a number");
                    Console.ReadLine();
                }
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("Please supply a number");
                Console.ReadLine();                
            }
            catch (Exception ex)
            {                
                Console.WriteLine(ex.Message);
            }
        }

        private static string Convert(Int64 number)
        {
            return new NumbersToEnglishBuilder().ToEnglish(number);
        }
    }
}
